#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)

#include <stdio.h>

#define ROW 102
#define COL 102

int calculate(int row, int col, char board[ROW][COL]);

int main()
{
	int n = 0;
	int m = 0;
	scanf("%d %d", &n, &m);
	getchar();

	char board[ROW][COL] = { 0 };
	int row = 1;
	int col = 1;
	for (row = 1; row <= n; row++)
	{
		for (col = 1; col <= m; col++)
		{
			scanf("%c", &board[row][col]);
		}

		getchar();
	}

	for (row = 1; row <= n; row++)
	{
		for (col = 1; col <= m; col++)
		{
			if (board[row][col] == '*')
			{
				printf("*");
			}
			else if (board[row][col] == '?')
			{
				printf("%d", calculate(row, col, board));
			}
			else
			{
				;
			}
		}

		printf("\n");
	}


	return 0;
}

int calculate(int row, int col, char board[ROW][COL])
{
	int count = 0;
	int i = 0;
	int j = 0;

	for (i = row - 1; i <= row + 1; i++)
	{
		for (j = col - 1; j <= col + 1; j++)
		{
			if (board[i][j] == '*')
			{
				count++;
			}
		}
	}

	return count;
}